#!/bin/sh

touch /etc/crontabs/root

uci set luci.main.lang=zh_cn
#设置默认主题
#uci set luci.main.mediaurlbase=/luci-static/bootstrap_mod
uci commit luci

uci set system.@system[0].timezone=CST-8
uci set system.@system[0].zonename=Asia/Shanghai
uci commit system

uci set fstab.@global[0].anon_mount=1
uci commit fstab

ln -sf /sbin/ip /usr/bin/ip

sed -i '/lienol/d' /etc/opkg/distfeeds.conf
#sed -i 's/downloads.openwrt.org/openwrt.proxy.ustclug.org/g' /etc/opkg/distfeeds.conf
#sed -i 's/http/https/g' /etc/opkg/distfeeds.conf
sed -i "s/# //g" /etc/opkg/distfeeds.conf

#sed -i 's/root::0:0:99999:7:::/root:$1$V4UetPzk$CYXluq4wUazHjmCDBCqXF.:0:0:99999:7:::/g' /etc/shadow

#uci set dhcp.lan.ra='server'
#uci set dhcp.lan.dhcpv6='server'
#uci set dhcp.lan.ra_management='1'
#uci set dhcp.lan.ra_default='1'
#uci set dhcp.@dnsmasq[0].localservice=0
#uci set dhcp.@dnsmasq[0].nonwildcard=0
#uci commit dhcp

#DNS重定向
sed -i '/REDIRECT --to-ports 53/d' /etc/firewall.user
echo "# iptables -t nat -A PREROUTING -p udp --dport 53 -j REDIRECT --to-ports 53" >> /etc/firewall.user

sed -i '/option disabled/d' /etc/config/wireless
sed -i '/set wireless.radio${devidx}.disabled/d' /lib/wifi/mac80211.sh
wifi up

date=`date +%m.%d`
date1=`date +%h`
sed -i '/DISTRIB_REVISION/d' /etc/openwrt_release
echo "DISTRIB_REVISION='v$date'" >> /etc/openwrt_release
sed -i '/DISTRIB_RELEASE/d' /etc/openwrt_release
echo "DISTRIB_RELEASE='v$date1'" >> /etc/openwrt_release
sed -i '/DISTRIB_DESCRIPTION/d' /etc/openwrt_release
echo "DISTRIB_DESCRIPTION='Openwrt '" >> /etc/openwrt_release

sed -i 's/LuCI Master/kenzo/g' /usr/lib/lua/luci/version.lua
sed -i 's/LuCI openwrt-18.06 branch/kenzo/g' /usr/lib/lua/luci/version.lua
sed -i 's/LuCI 17.01 Lienol/kenzo/g' /usr/lib/lua/luci/version.lua
sed -i 's/LuCI openwrt-21.02 branch/kenzo/g' /usr/lib/lua/luci/version.lua
sed -i '/luciversion/d' /usr/lib/lua/luci/version.lua
echo 'luciversion = "DEC"' >> /usr/lib/lua/luci/version.lua

# 删除状态页不需显示的
rm -rf /usr/lib/lua/luci/view/admin_status/index
#mv -f /usr/lib/lua/luci/view/admin_status/index /usr/lib/lua/luci/view/admin_status/index_backup 2>/dev/null

#禁用某些可能会自启动且用不上的依赖包服务
/etc/init.d/php7-fastcgi disable 2>/dev/null
/etc/init.d/php7-fpm disable 2>/dev/null
/etc/init.d/softethervpnbridge disable 2>/dev/null
/etc/init.d/softethervpnserver disable 2>/dev/null
/etc/init.d/softethervpnclient disable 2>/dev/null
/etc/init.d/haproxy disable 2>/dev/null
/etc/init.d/kcptun disable 2>/dev/null

rm -rf /tmp/luci-*cache

exit 0
